package ACM;

import java.util.Scanner;

/**
 * 尽力了之  扰乱字符串
 */
public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.nextLine();
        String s2 = scanner.nextLine();

        if (s1 == null && s2 != null || s2 == null && s1 != null || s1.length() != s2.length())
            System.out.println("false");

        boolean[][][] dp = new boolean[s1.length()][s2.length()][s1.length() + 1];
        for (int i = 0; i < s1.length(); i++) {
            for (int j = 0; j < s2.length(); j++) {
                if (s1.charAt(i) == s2.charAt(j)) dp[i][j][1] = true;
            }
        }
        for (int len = 2; len <= s1.length(); len++) {
            for (int i = 0; i < s1.length(); i++) {
                for (int j = 0; j < s2.length(); j++) {
                    for (int k = 1; k < len; k++) {
                        if (i + k < s1.length() &&
                                j + k < s1.length() &&
                                j + len - k < s1.length() &&
                                ((dp[i][j][k] && dp[i + k][j + k][len - k])
                                        || (dp[i][j + len - k][k] &&
                                        dp[i + k][j][len - k]))) {
                            dp[i][j][len] = true;
                            break;
                        }
                    }
                }
            }
        }
        if (dp[0][0][s1.length()]){
            System.out.println("true");
        }else {
            System.out.println("false");
        }
    }
}


